import React, { useContext } from 'react'
import './App.less'
import context from './context/context'

export const Son2:React.FC =() => {
   const value = useContext(context)
   console.log('value',value);//{ dispatch, state: {numberValue: ?} }
   const {dispatch, state:{numberValue}} = value

   const addNumber = () =>  {
      dispatch({
         type:'change2',
         payload:2
      })
   }
    return (
      <>
      <div className='Son2'>
         我是Son2, Provider中的值{numberValue}
         <button onClick={addNumber}>点击变成2 </button>
      </div>
       </>
    )
  }
